using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ScoreManager : MonoBehaviour
{
    public Text LifeManager;//显示生命值和分数的文本框
    public int Life;//生命值
    public int S;//分数
    public bool GameOver;//是否游戏结束
    void Start()//初始化三个变量
    {
        S=0;
        Life=3;
        GameOver=false;
    }
    public void Hit()//若被击中，则执行操作
    {
        Life--;
        if (Life==0) GameOver=true;
        if (Life<0) Life=0;
    }
    void Update()
    {
        if (Life>0) S+=(int)(Time.deltaTime*1000);//分数随时间增加
        LifeManager.text="Life:"+Life+"\nScore:"+S;//显示生命值和分数
    }
}
